﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KendoMvcUI.Common;
using KendoMvcUI.Core;
using System.Web.Mvc;

namespace KendoMvcUI.UI
{
    public class Menu:KendoUIBase
    {
        public Menu(KendoUIControlSettings settings,ViewContext context,IViewDataContainer viewDataContainer)
            :base(settings,context,viewDataContainer)
        { }

    }
    public class MenuSettings : KendoBindingBase
    {
        public MenuSettings()
            : base("kendoMenu")
        { }
        [PropertySetting(IsIngoreForJavaScript=true)]
        public Action<AnimationSettings> Animation { get; set; }
        public bool? CloseOnClick { get; set; }
        /// <summary>
        /// Specifies Menu opening direction. Can be "top", "bottom", "left", "right". 
        /// You can also specify different direction for root and sub menu items, separating them with space
        /// </summary>
        public string Direction { get; set; }
        /// <summary>
        /// Specifies the delay in ms before the menu is opened/closed - 
        /// used to avoid accidental closure on leaving
        /// default:100
        /// </summary>
        public int? HoverDelay { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public bool? OpenOnClick { get; set; }
        /// <summary>
        /// default: "horizontal"
        /// Root menu orientation. Could be horizontal or vertical.
        /// </summary>
        public string Orientation { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string PopupCollision { get; set; }

        #region 事件
        public string On_Close { get; set; }
        public string On_Open { get; set; }
        public string On_Activate { get; set; }
        public string On_Deactivate { get; set; }
        public string On_Select { get; set; }
        #endregion

        public override string ToJsSettings()
        {
            var js= base.ToJsSettings();
            if (!js.EndsWith(","))
                js += ",";
            if (Animation != null)
            {
                AnimationSettings animation = new AnimationSettings();
                Animation(animation);
                js += animation.ToString() + ",";
            }
            return js.TrimEnd(',');
        }
    }
}
